package com.hex.ds.hdtp.core.app.script.analyze.converter;

import com.hex.ds.hdtp.core.app.common.enums.BasicListStatus;
import com.hex.ds.hdtp.core.app.common.util.FileUtil;
import com.hex.ds.hdtp.core.app.script.analyze.dto.request.ScriptAnalyzeListRequestDto;
import com.hex.ds.hdtp.core.app.script.analyze.dto.request.ScriptAnalyzeTaskRequestDto;
import com.hex.ds.hdtp.core.app.script.analyze.dto.response.ScriptAnalyzeTaskResponseDto;
import com.hex.ds.hdtp.core.inf.script.analyze.po.ScriptAnalyzeTaskPo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.io.File;
import java.util.List;

/**
 * @Package com.hex.ds.hdtp.core.app.script.analyze.converter
 * @ClassName IScriptAnalyzeTaskConverter
 * @Description 脚本转换任务DTO对象与PO对象转换器
 * @Author gj.xu
 * @Date 2023/12/7 15:11
 * @Version v2.0
 **/
@Mapper(componentModel = "spring", imports = {BasicListStatus.class, FileUtil.class})
public interface IScriptAnalyzeTaskConverter {

    ScriptAnalyzeTaskPo toScriptAnalyzeTaskPo(ScriptAnalyzeTaskRequestDto scriptAnalyzeTaskRequestDto);

    ScriptAnalyzeTaskResponseDto toScriptAnalyzeTaskResponseDto(ScriptAnalyzeTaskPo scriptAnalyzeTaskPo);

    List<ScriptAnalyzeTaskResponseDto> toScriptAnalyzeTaskResponseDtoList(List<ScriptAnalyzeTaskPo> scriptAnalyzeTaskPos);

    @Mapping(target = "pkId", ignore = true)
    @Mapping(target = "analyzeTaskPkId", source = "scriptAnalyzeTaskPo.pkId")
    @Mapping(target = "sourceFilePath", source = "file.parent")
    @Mapping(target = "sourceFileName", source = "file.name")
    @Mapping(target = "status", expression = "java(BasicListStatus.TODO.name())")
    ScriptAnalyzeListRequestDto toScriptAnalyzeListRequestDto(ScriptAnalyzeTaskPo scriptAnalyzeTaskPo, File file);

}
